import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, ManyToOne } from 'typeorm';
import { Project } from '../project/project.entity';
import { User } from '../user/user.entity';
import { ProjectShare } from '../project/project-share.entity';

@Entity()
export class Submission {
  @PrimaryGeneratedColumn()
  id: number;

  @Column('json')
  data: any;

  @CreateDateColumn()
  submittedAt: Date;

  @ManyToOne(() => Project, (project) => project.submissions)
  project: Project;

  @ManyToOne(() => User, { nullable: true })
  recommendedBy: User; // 推荐该提交的管理员

  @ManyToOne(() => ProjectShare, { nullable: true })
  projectShare: ProjectShare; // 关联的项目分享记录
}